class Node:
    """
        文件节点
    """
    def __init__(self, file_name, file_type="dir"):
        self.file_name = file_name  # 文件名
        self.file_type = file_name  # dir 文件夹, file 文件
        self.children = []  # 子节点
        self.parent = None  # 父节点
    
    def __repr__(self):
        return self.file_name
        

class FileSystemTree:
    def __init__(self):
        self.root = Node("/")
        self.now = self.root  # 当前目录指针
        
    
    def mkdir(self, name):
        """
            创建文件夹， name 文件夹名称
        """
        # / 用来区分文件和文件夹
        if name[-1] != "/":
            name += "/"
        
        node = Node(name)
        self.now.children.append(node)
    
    def cd(self, name):
        """
            移动
        """
        if name[-1] != "/":
            name += "/"
        
        for children in self.now.children:
            if children.file_name == name:
                self.now = children
                return
        raise ValueError("文件不存在")

file = FileSystemTree()
file.mkdir("bin/")
file.mkdir("var/")

print(file.now.children)
file.cd("bin/")
file.mkdir("test/")
print(file.now.children)